
import de.javasoft.plaf.synthetica.SyntheticaBlackStarLookAndFeel;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Consoler.java
 *
 * Created on 03-23-2012, 05:21:56 PM
 */
/**
 *
 * @author ronaldo
 */
public class Consoler extends javax.swing.JFrame {

    /** Creates new form Consoler */
    public Consoler() {
        initComponents();
        setSyntheticaBlueMoonLF();
        //this.lblState.setVisible(false);
        lblCancel.setVisible(false);
        if (!F.exists()) {
            Crear();
        } else {
            LFile();
        }
        SFolder();
        ScrollValues();
    }
    private File F = new File("ConfigDBF.ddc");

    private void LFile() {
        BufferedReader BR = null;
        try {
            BR = new BufferedReader(new FileReader(F));
            do {
                String Linea = BR.readLine();
                if (Linea == null) {
                    break;
                }
                ur2.addItem(Linea);
            } while (true);
            BR.close();
        } catch (IOException ex) {
            Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                BR.close();
            } catch (IOException ex) {
                Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    private void Crear() {
        try {
            F.createNewFile();
        } catch (IOException ex) {
            Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pm_URI = new javax.swing.JPopupMenu();
        mn_Add = new javax.swing.JMenuItem();
        mn_Remove = new javax.swing.JMenuItem();
        jLabel2 = new javax.swing.JLabel();
        ur1 = new javax.swing.JTextField();
        ColapseState = new com.l2fprod.common.swing.JCollapsiblePane();
        lblState = new javax.swing.JLabel();
        lblFolder = new javax.swing.JLabel();
        lblBasura = new javax.swing.JLabel();
        ur2 = new javax.swing.JComboBox();
        lblCancel = new javax.swing.JLabel();
        lblNRegistro = new javax.swing.JLabel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel3 = new javax.swing.JPanel();
        jSplitPane2 = new javax.swing.JSplitPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollBar1 = new javax.swing.JScrollBar();
        jScrollPane1 = new javax.swing.JScrollPane();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtInput = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        txtLog = new javax.swing.JTextArea();
        jPanel4 = new javax.swing.JPanel();
        jSplitPane3 = new javax.swing.JSplitPane();
        JP_Columns = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtColumns = new javax.swing.JTextArea();
        JP_DBF = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        txtDBF = new javax.swing.JTextArea();

        mn_Add.setText("Agregar directorio");
        pm_URI.add(mn_Add);

        mn_Remove.setText("Quitar directorio");
        pm_URI.add(mn_Remove);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setAlwaysOnTop(true);

        jLabel2.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        jLabel2.setText("URL");

        ur1.setEditable(false);
        ur1.setText("jdbc:dbf:////");

        ColapseState.setCollapsed(true);
        com.l2fprod.common.swing.PercentLayout percentLayout1 = new com.l2fprod.common.swing.PercentLayout();
        percentLayout1.setGap(2);
        percentLayout1.setOrientation(1);
        ColapseState.getContentPane().setLayout(percentLayout1);

        lblState.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ajax-loader.gif"))); // NOI18N
        ColapseState.getContentPane().add(lblState);

        lblFolder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Folder.png"))); // NOI18N
        lblFolder.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lblFolder.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblFolderMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblFolderMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblFolderMouseExited(evt);
            }
        });

        lblBasura.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Basura.png"))); // NOI18N
        lblBasura.setBorder(null);
        lblBasura.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lblBasura.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblBasuraMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lblBasuraMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lblBasuraMouseExited(evt);
            }
        });

        ur2.setEditable(true);
        ur2.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                ur2ItemStateChanged(evt);
            }
        });

        lblCancel.setFont(new java.awt.Font("DejaVu Sans", 1, 12));
        lblCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Cancelar.png"))); // NOI18N
        lblCancel.setText("Cancelar");
        lblCancel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lblCancel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblCancelMouseClicked(evt);
            }
        });

        lblNRegistro.setText("Nº");

        jSplitPane1.setDividerLocation(180);
        jSplitPane1.setOneTouchExpandable(true);

        jPanel3.setLayout(new java.awt.BorderLayout());

        jSplitPane2.setDividerLocation(150);
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OutPut", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Serif", 1, 12))); // NOI18N
        jPanel2.setPreferredSize(new java.awt.Dimension(899, 283));

        jScrollBar1.addAdjustmentListener(new java.awt.event.AdjustmentListener() {
            public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {
                jScrollBar1AdjustmentValueChanged(evt);
            }
        });

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        jScrollPane7.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane7.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane7.setAutoscrolls(true);
        jScrollPane7.setPreferredSize(null);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null}
            },
            new String [] {
                "Resultados"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setFillsViewportHeight(true);
        jScrollPane7.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setResizable(false);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(100);

        jScrollPane1.setViewportView(jScrollPane7);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 718, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
        );

        jSplitPane2.setBottomComponent(jPanel2);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Serif", 1, 12))); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(899, 196));

        txtInput.setColumns(10);
        txtInput.setForeground(new java.awt.Color(53, 102, 212));
        txtInput.setLineWrap(true);
        txtInput.setRows(5);
        txtInput.setText("Code");
        txtInput.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                txtInputFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtInputFocusLost(evt);
            }
        });
        txtInput.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtInputKeyPressed(evt);
            }
        });
        jScrollPane2.setViewportView(txtInput);

        txtLog.setColumns(20);
        txtLog.setEditable(false);
        txtLog.setForeground(new java.awt.Color(253, 71, 26));
        txtLog.setRows(5);
        txtLog.setText("LOG Programacion\n");
        jScrollPane3.setViewportView(txtLog);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
        );

        jSplitPane2.setLeftComponent(jPanel1);

        jPanel3.add(jSplitPane2, java.awt.BorderLayout.CENTER);

        jSplitPane1.setRightComponent(jPanel3);

        jPanel4.setLayout(new java.awt.BorderLayout());

        jSplitPane3.setDividerLocation(150);
        jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        JP_Columns.setBorder(javax.swing.BorderFactory.createTitledBorder("Column's"));

        txtColumns.setColumns(20);
        txtColumns.setEditable(false);
        txtColumns.setForeground(new java.awt.Color(3, 133, 50));
        txtColumns.setRows(5);
        jScrollPane4.setViewportView(txtColumns);

        javax.swing.GroupLayout JP_ColumnsLayout = new javax.swing.GroupLayout(JP_Columns);
        JP_Columns.setLayout(JP_ColumnsLayout);
        JP_ColumnsLayout.setHorizontalGroup(
            JP_ColumnsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
        );
        JP_ColumnsLayout.setVerticalGroup(
            JP_ColumnsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
        );

        jSplitPane3.setBottomComponent(JP_Columns);

        JP_DBF.setBorder(javax.swing.BorderFactory.createTitledBorder("File DBF"));

        txtDBF.setColumns(10);
        txtDBF.setEditable(false);
        txtDBF.setForeground(new java.awt.Color(166, 28, 115));
        txtDBF.setLineWrap(true);
        txtDBF.setRows(5);
        jScrollPane5.setViewportView(txtDBF);

        javax.swing.GroupLayout JP_DBFLayout = new javax.swing.GroupLayout(JP_DBF);
        JP_DBF.setLayout(JP_DBFLayout);
        JP_DBFLayout.setHorizontalGroup(
            JP_DBFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
        );
        JP_DBFLayout.setVerticalGroup(
            JP_DBFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
        );

        jSplitPane3.setLeftComponent(JP_DBF);

        jPanel4.add(jSplitPane3, java.awt.BorderLayout.CENTER);

        jSplitPane1.setLeftComponent(jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 951, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(ColapseState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ur1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(ur2, javax.swing.GroupLayout.PREFERRED_SIZE, 338, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblFolder)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblBasura)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 220, Short.MAX_VALUE)
                        .addComponent(lblCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lblNRegistro)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(lblBasura, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblFolder, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblNRegistro)
                        .addComponent(lblCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(ColapseState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(ur1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(ur2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents
    Thread TheadCodeS;
    private void txtInputKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtInputKeyPressed
        // TODO add your handling code here:
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            if (txtInput.getText().trim().isEmpty()) {
                txtInput.setText(this.AntCons);
            }
        }
        if (evt.getKeyCode() == KeyEvent.VK_F5) {
            if (txtInput.getText().trim().isEmpty()) {
                evt.consume();
                return;
            }
            txtInput.setEditable(false);
            txtInput.setEnabled(false);
            lblCancel.setVisible(true);
            this.ColapseState.setCollapsed(false);
            TheadCodeS = new Thread(new Runnable() {

                public void run() {
                    Table_Consult();
                    txtInput.setEditable(true);
                    txtInput.setEnabled(true);
                    lblCancel.setVisible(false);
                    ColapseState.setCollapsed(true);
                }
            });
            TheadCodeS.start();
        }
    }//GEN-LAST:event_txtInputKeyPressed

    private void lblBasuraMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblBasuraMouseEntered
        // TODO add your handling code here:
        lblBasura.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    }//GEN-LAST:event_lblBasuraMouseEntered

    private void lblBasuraMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblBasuraMouseExited
        // TODO add your handling code here:
        lblBasura.setBorder(null);
    }//GEN-LAST:event_lblBasuraMouseExited

    private void lblFolderMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblFolderMouseEntered
        // TODO add your handling code here:
        lblFolder.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    }//GEN-LAST:event_lblFolderMouseEntered

    private void lblFolderMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblFolderMouseExited
        // TODO add your handling code here:
        lblFolder.setBorder(null);
    }//GEN-LAST:event_lblFolderMouseExited

    private void ur2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ur2ItemStateChanged
        // TODO add your handling code here:
        SFolder();
    }//GEN-LAST:event_ur2ItemStateChanged

    private void txtInputFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtInputFocusGained
        // TODO add your handling code here:
        if (txtInput.getText().trim().equals("Code")) {
            txtInput.setText("");
        }
    }//GEN-LAST:event_txtInputFocusGained

    private void txtInputFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtInputFocusLost
        if (txtInput.getText().trim().isEmpty()) {
            txtInput.setText("Code");
        }
    }//GEN-LAST:event_txtInputFocusLost

    private void lblCancelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCancelMouseClicked
        // TODO add your handling code here:
        TheadCodeS.interrupt();
        txtInput.setEditable(true);
        txtInput.setEnabled(true);
        ColapseState.setCollapsed(true);
        lblCancel.setVisible(false);
    }//GEN-LAST:event_lblCancelMouseClicked

    private void lblFolderMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblFolderMouseClicked
        // TODO add your handling code here:
        AsLocation();
    }//GEN-LAST:event_lblFolderMouseClicked

    private void lblBasuraMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblBasuraMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_lblBasuraMouseClicked

    private void jScrollBar1AdjustmentValueChanged(java.awt.event.AdjustmentEvent evt) {//GEN-FIRST:event_jScrollBar1AdjustmentValueChanged
        // TODO add your handling code here:
        jScrollPane7.getVerticalScrollBar().setValue(jScrollBar1.getValue());
    }//GEN-LAST:event_jScrollBar1AdjustmentValueChanged

    private void AsLocation() {
        JFolderChooser JFC = new JFolderChooser(this, true);
        JFC.setVisible(true);
        if (JFolderChooser.Result == JFolderChooser.Acept) {
            AppendFile(JFolderChooser.Directory);
        }
    }

    private void AppendFile(String DC) {
        FileWriter fichero;
        try {
            fichero = new FileWriter(F, true);
            PrintWriter pw = new PrintWriter(fichero);
            pw.println(DC);
            ur2.addItem(DC);
            ur2.setSelectedItem(DC);
            pw.close();
        } catch (IOException ex) {
            Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void SFolder() {
        Thread TheadCode = new Thread(new Runnable() {

            public void run() {
                try {
                    txtDBF.setText("");
                    File f = new File(ur2.getSelectedItem().toString());
                    File[] files = f.listFiles();
                    for (int i = 0; i < files.length; i++) {
                        if (files[i].getAbsoluteFile().toString().toLowerCase().lastIndexOf(".dbf") >= 0) {
                            txtDBF.setText(txtDBF.getText() + files[i].getName() + "\n");
                        }
                    }
                } catch (Exception e) {
                }
            }
        });
        TheadCode.start();
    }

    private void setSyntheticaBlueMoonLF() {
        try {
            UIManager.setLookAndFeel(new SyntheticaBlackStarLookAndFeel());
            SwingUtilities.updateComponentTreeUI(this);
        } catch (Exception e) {
        }

    }
    String AntCons = "";
    Statement stmt = null;
    Connection conn = null;

    private void Table_Consult() {
        String Selected = "";//Parametro de seleccion
        try {
            //************************************
            //ESTABLECIENDO PARAMETROS DE CONEXION
            //************************************
            String jdbURL = this.ur1.getText().trim() + this.ur2.getSelectedItem().toString();
            Class.forName("com.caigen.sql.dbf.DBFDriver");

            Properties props = new Properties();
            props.setProperty("delayedClose", "0");

            conn = DriverManager.getConnection(jdbURL, props);
            stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            //************************************
            //CONEXION ESTABLECIDA
            //************************************

            ResultSet rs;//Parametro de resultado    
            //Determinando seleccion de consulta
            try {
                Selected = txtInput.getSelectedText();
                Selected.length();
            } catch (Exception e) {
                Selected = this.txtInput.getText();
            }
            //Fin de la determinacion de consulta
            ResultSetMetaData resultSetMetaData = null;//Retomando el resultado a MetaData
            int nc = 0;//Numero de Columnas

            int rec = 0;

            rs = stmt.executeQuery(Selected);//Ejecución de Query - Resultado();
            resultSetMetaData = rs.getMetaData();//Retomando el resultado a MetaData
            nc = resultSetMetaData.getColumnCount();//Numero de Columnas

            //Determinando las columnas

            String[] Columns = new String[nc];
            txtColumns.setText("");
            
            for (int i = 0; i < nc; i++) {//Asignacion de Columnas
                Columns[i] = resultSetMetaData.getColumnName(i + 1);
                txtColumns.append(resultSetMetaData.getColumnName(i + 1)
                        + "  \t" + resultSetMetaData.getColumnTypeName(i + 1)
                        + "  \t" + resultSetMetaData.getPrecision(i + 1)
                        + "  \t" + resultSetMetaData.getScale(i + 1) + "\n");

            }
            jTable1 = new javax.swing.JTable();
            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][]{},
                    new String[]{}));
            AS_Model(Columns);
            DefaultTableModel Model = (DefaultTableModel) jTable1.getModel();
            while (rs.next()) {
                rec++;
                this.lblNRegistro.setText(String.valueOf(rec));
                Vector v = new Vector();
                for (int i = 0; i < nc; i++) {
                    v.add(rs.getObject(i + 1));
                }
                Model.addRow(v);
            }
            
            //java.awt.Dimension d = new java.awt.Dimension(jTable1.getColumnCount() * 100, (jTable1.getRowHeight() * jTable1.getRowCount()) + 100);
            java.awt.Dimension d = new java.awt.Dimension(jTable1.getColumnCount() * 100, this.jScrollPane1.getHeight()-10);
            jTable1.setModel(Model);
            jScrollPane7.setPreferredSize(d);
            jScrollPane7.setSize(d);
            jScrollPane7.setViewportView(jTable1);
//            for (int i = 0; i < Model.getColumnCount(); i++) {
//                jTable1.getColumnModel().getColumn(i).setPreferredWidth(100);
//                jTable1.getColumnModel().getColumn(i).setWidth(100);
//            }
            
            ScrollValues();

        } catch (SQLException ex) {
            this.txtLog.append("SQLException: " + ex.getMessage() + "\n");
            try {
                stmt.executeUpdate(Selected);
                this.txtLog.append("-----****-----\nQueryUpdate: Succesfull -----****-----"+ "\n");
                //Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex1) {
                this.txtLog.append("SQLException-Error Query Update: " + ex.getMessage() + "\n");
                //Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex1);
            }
        } //        catch (ClassNotFoundException ex) {
        //            this.txtLog.append("ClassNotFoundexception: " + ex.getMessage() + "\n");
        //            //Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex);
        //        }
        catch (Exception ex) {
            this.txtLog.append("Exception: " + ex.getMessage() + "\n");
        }
        this.txtLog.append("****************\nQuery:" + Selected + "\n");
        this.txtDBF.setCaretPosition(txtDBF.getDocument().getLength());
        this.txtLog.setCaretPosition(txtLog.getDocument().getLength());
        this.txtInput.requestFocus();
        try {
            ///**********************
            //Cerrando Conexion
            ///**********************
            stmt.close();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(Consoler.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void ScrollValues() {
        try {
            jScrollBar1.setMaximum(jScrollPane7.getVerticalScrollBar().getMaximum());
            jScrollBar1.setMinimum(jScrollPane7.getVerticalScrollBar().getMinimum());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    private void AS_Model(String[] Columns) {
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][]{}, Columns));
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Consoler.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Consoler.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Consoler.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Consoler.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Consoler().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.l2fprod.common.swing.JCollapsiblePane ColapseState;
    private javax.swing.JPanel JP_Columns;
    private javax.swing.JPanel JP_DBF;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollBar jScrollBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JSplitPane jSplitPane3;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel lblBasura;
    private javax.swing.JLabel lblCancel;
    private javax.swing.JLabel lblFolder;
    private javax.swing.JLabel lblNRegistro;
    private javax.swing.JLabel lblState;
    private javax.swing.JMenuItem mn_Add;
    private javax.swing.JMenuItem mn_Remove;
    private javax.swing.JPopupMenu pm_URI;
    private javax.swing.JTextArea txtColumns;
    private javax.swing.JTextArea txtDBF;
    private javax.swing.JTextArea txtInput;
    private javax.swing.JTextArea txtLog;
    private javax.swing.JTextField ur1;
    private javax.swing.JComboBox ur2;
    // End of variables declaration//GEN-END:variables
}
